package com.obtk.service.impl;

import com.obtk.mapper.CstLinkmanMapper;
import com.obtk.mapper.SelChanceMapper;
import com.obtk.model.SelChance;
import com.obtk.service.SelChanceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 功能说明
 *
 * @author Mr.Sun
 * @date 2023-04-05 15:40:22
 */
@Service
public class SelChanceServiceImpl implements SelChanceService {
    @Autowired
    private SelChanceMapper selChanceMapper;
    @Override
    public List<SelChance> selectSelChance(SelChance selChance) {
        return selChanceMapper.selectSelChance(selChance);
    }

    @Override
    public SelChance selectByChcCustName(String chcCustName) {
        return selChanceMapper.selectByChcCustName(chcCustName);
    }

    @Override
    public int register(SelChance selChance) {
        selChance.setChcCreateDate(new Date());
        selChance.setChcDueDate(new Date());
        selChance.setChcBirthday(new Date());
        selChance.setChcDueStatus(1);
        int insert = selChanceMapper.insert(selChance);
        return insert;
    }


    @Override
    public SelChance selectBySelChanceId(Integer id) {
        return selChanceMapper.selectBySelChanceId(id);
    }

    @Override
    public int updateBySelChanceId(SelChance selChance) {
        selChance.setChcBirthday(new Date());
        selChance.setChcCreateDate(new Date());
        selChance.setChcDueDate(new Date());
        return selChanceMapper.updateBySelChanceId(selChance);
    }

    @Override
    public int updateStatusBatch(List<String> ids, Integer chcDueStatus) {
        Map<String,Object> params = new HashMap<String,Object>(2);
        System.out.println("selChance:"+ids);
        System.out.println("selChance"+chcDueStatus);
        params.put("ids",ids);
        params.put("chcDueStatus",chcDueStatus);
        return selChanceMapper.updateStatusBatch(params);
    }
}
